﻿[output_none]

	[if:(action_param:'pageform_title')!='' && (action_param:'pageform_url')!='']
	
		[var:'pageform_lang'=(encode_sql:(action_param:'pageform_lang'))]
		[var:'pageform_title'=(encode_sql:(action_param:'pageform_title'))]
		[var:'pageform_url'=(encode_sql:(action_param:'pageform_url'))]
		[var:'pageform_target'=(encode_sql:(action_param:'pageform_target'))]
		[if:(action_param:'pageform_page')==''][var:'pageform_page'=1][else][var:'pageform_page'=(encode_sql:(action_param:'pageform_page'))][/if]

		[var:'sql_save_url'='
			UPDATE		SHb_menus
			SET			target_url		= \'' + $pageform_url + '\'
						, target_window	= \'' + $pageform_target + '\'
			WHERE		_k2_pageid		= \'' + $pageform_page + '\'
			']
			
			
		[Inline: -database='SHoebox', -sql=$sql_save_url]
			[if:(error_currenterror:-errorcode)==0]
				
				[var:'sql_get_menuid'='SELECT _k1_menuid FROM SHb_menus WHERE _k2_pageid = \'' + $pageform_page + '\'']
				[inline: -database='SHoebox', -sql=$sql_get_menuid]
					[if:(error_currenterror:-errorcode)==0]
						
						[var:'sql_update_menu'='
							UPDATE   SHb_translations_menus
							SET      label          = \'' + $pageform_title + '\'
							WHERE    _k2_menuid     = \'' + (field:'_k1_menuid') + '\'
							  AND    _k2_languageid = \'' + #pageform_lang + '\'
						']
						
						[inline: -database='SHoebox', -sql=$sql_update_menu]
							[if:(error_currenterror:-errorcode)==0]
								[var:'output_message'='URL Saved']
							[else]
								[var:'output_message'='An error occured while saving URL']
							[/if]
						[/inline]
						
						
					[else]
						[var:'output_message'='An error occured while saving URL']
					[/if]
				[/inline]
				
			[else]
				[var:'output_message'='An error occured while saving URL']
			[/if]
			
		[/inline]
	
	[else]
	
		[var:'output_message'='An error occured while saving URL']
		
	[/if]
	
[/output_none]		
<b>[var:'output_message',-encodenone]</b>